package cn.myit.controller;

import cn.myit.domain.Teacher;
import cn.myit.service.ITeacherService;
import cn.myit.utils.Myeasypoi;
import cn.myit.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/sc")
public class shangccontroller {
    @Autowired
    ITeacherService teacherService;
    @PutMapping("/upload")
    public R upload(MultipartFile file) throws IOException {
//        String filename = file.getOriginalFilename();
//        String filePath = path + filename;
//        File file1 = new File(filePath);
//        if(!file1.exists()){
//            file1.mkdirs();
//        }
//        file.transferTo(file1);
//
//        return  R.ok();
        return R.ok();
    }
    /**
     * @Description: 老师信息导出
     * @Author: Neuronet
     * @Date: 2023/9/25 16:49
     * @Return:
     **/
    @GetMapping("/export")
    public void export(HttpServletResponse response) throws IOException {
        List<Teacher> list = teacherService.list();
        Myeasypoi.exportExcel(list, "智慧校园管理系统-老师信息", "老师信息表", Teacher.class, "Teachers", response);
    }


}
